package com.lzy.cloud.order.service.impl;

import com.lzy.cloud.order.dtos.OrderCouponLogDto;
import com.lzy.cloud.order.entity.OrderCouponLog;
import com.lzy.cloud.order.mapper.OrderCouponLogMapperExt;
import com.lzy.cloud.order.service.OrderCouponLogService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:订单中券流向记录
 * @author: liyun
 * @create: 2018-07-05 16:11
 */
@Service
public class OrderCouponLogServiceImpl implements OrderCouponLogService {
    @Autowired
    private OrderCouponLogMapperExt orderCouponLogMapperExt;

    @Override
    public List<OrderCouponLogDto> queryListByOrderId(String orderId) {
        return orderCouponLogMapperExt.queryListByOrderId(orderId);
    }

    @Override
    public Long create(OrderCouponLogDto orderCouponLogDto) {
        OrderCouponLog orderCouponLog = DozerUtils.map(orderCouponLogDto, OrderCouponLog.class);
        return orderCouponLogMapperExt.insertSelective(orderCouponLog)>0 ? orderCouponLog.getId() : 0;
    }

    @Override
    public Boolean delete(Long id) {
        return orderCouponLogMapperExt.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public List<OrderCouponLogDto> selectList(OrderCouponLogDto orderCouponLogDto) {
        return orderCouponLogMapperExt.selectList(orderCouponLogDto);
    }

    @Override
    public Boolean updateManyLog(OrderCouponLogDto orderCouponLogDto, String couponIds) {
        return orderCouponLogMapperExt.updateManyLog(orderCouponLogDto,couponIds)>0;
    }
}
